<template>
   <div>
      <div style="width:60%;margin:0 auto">
         <el-table
            :data="commentList"
            style="width:100%">

            <el-table-column
              prop="commentId"
              label="编号"
              width="50">
              {{commentList.commentId}} 
            </el-table-column>

            <el-table-column
              prop="commentContent"
              label="内容"
              width="300">
              {{commentList.commentContent}} 
            </el-table-column>

            <el-table-column
              prop="zanNum"
              label="点赞">
              <template slot-scope="scope">
                  <img style="width: 30px; height: 30px" :src="no" v-if="bl == false"  @click="dianji(scope.row.commentId)"> 
                  <img style="width: 30px; height: 30px" :src="ok" v-if="bl == true"  @click="dianji(scope.row.commentId)">                  
                    {{scope.row.num}} 
              </template>
            </el-table-column>          
    </el-table>
  </div>
   </div>
</template>

<script>
export default {
  
    data(){
        return{
            commentList:{},
            ok:require('../assets/zan_active.png'),
            no:require('../assets/zan.png'),
            show:"",
            loginObj:{},
            zanList:{},
            bl:false
        }
    },
    methods:{
       async getToekn(){
            let obj = await this.ajax.postSubmit("/project/admin/token",null,null);
            this.loginObj = obj;
            
        },
            async dianji(id){
                await this.getToekn(); 
                // alert(JSON.stringify(this.loginObj));
                if(this.loginObj.status == 1){
                    // let info = await this.ajax.getSubmit("/project/comment/num",{idAdmin:this.loginObj.data.adminId,idComment:id},null);
                    // if(info == "ok"){
                    //    let blObj = await this.ajax.getSubmit("/project/comment/check",{idAdmin:this.loginObj.data.adminId,idComment:id},null);
                    //     if(blObj == true){
                    //         this.bl = true;
                    //     }else{
                    //         this.bl = false;
                    //     }
                    //     this.init();
                    // }
                }else{
                    this.$router.push("/login");
                }          
            },
           async init(){
                let listObj = await this.ajax.setComments("/project/comment/findAll");
                alert(JSON.stringify(listObj.data));
                this.commentList = listObj.data;
            },

    },
     created(){
       this.init();
    }

}
</script>

<style>

</style>